package com.fs.api.enumeration;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fs.common.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import static com.fs.common.enumeration.BusinessExceptionEnum.PARAM_ERROR;

@Getter
@AllArgsConstructor
public enum AlertType {
    BUILDING_FIRE("建筑火灾"),
    VEHICLE_FIRE("车辆火灾"),
    CHEMICAL_FIRE("化工火灾"),
    FOREST_FIRE("森林火灾");

    @EnumValue
    @JsonValue
    private final String value;

    public static AlertType fromValue(String value) {
        for (AlertType alertType : AlertType.values()) {
            if (alertType.getValue().equals(value)) {
                return alertType;
            }
        }
        throw new BusinessException(PARAM_ERROR);
    }
}
